﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="Integer"
	type="http://metalx.org/Integer"
	static="true"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:int="http://metalx.org/i386/Functions/Integer"
	xmlns:short="http://metalx.org/i386/Functions/Short"
	xmlns:byte="http://metalx.org/i386/Functions/Byte"
	xmlns:hex="http://metalx.org/i386/Functions/Hexadecimal"
	xmlns:float="http://metalx.org/i386/Functions/Float"
	xmlns:dbl="http://metalx.org/i386/Functions/Double"
	xmlns:real="http://metalx.org/i386/Functions/Real"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:var="http://metalx.org/Variable"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:asc="http://metalx.org/Ansi/Ascii"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:inc="http://metalx.org/Intel/80386/Increment"
	xmlns:fpu="http://metalx.org/Intel/80386/FpuOperators"
	xmlns:ext="http://metalx.org/Intel/80386/ExtendedOperators"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands">

	<cls:field name="Value" type="http://metalx.org/Integer" offset="0"/>

	<cls:method name="Parse" type="http://metalx.org/Integer" static="true">
		<cls:parameter name="Value" type="http://metalx.org/String"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<int:Parse/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Random" type="http://metalx.org/Integer" static="true">
		<cpu:ExtendedOperator/>
		<ext:CopyTimestampCounterToAXDX/>

		<int:CreateObject/>

		<cls:return/>
	</cls:method>

	<cls:method name="ToHexadecimal" type="http://metalx.org/Hexadecimal">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopySIAddressToAXAndIncrementSI/>

		<hex:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToFloat" type="http://metalx.org/Float">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushIntegerAtSIAddressToST0/>

		<cpu:WaitForFloatingPointUnit/>

		<float:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToDouble" type="http://metalx.org/Double">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushIntegerAtSIAddressToST0/>

		<cpu:WaitForFloatingPointUnit/>

		<dbl:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToReal" type="http://metalx.org/Real">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<fpu:ResetFpu/>

		<fpu:PushIntegerAtSIAddressToST0/>

		<cpu:WaitForFloatingPointUnit/>

		<real:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToShort" type="http://metalx.org/Short">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopySIAddressToAXAndIncrementSI/>
		
		<short:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToByte" type="http://metalx.org/Byte">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopySIAddressToAXAndIncrementSI/>
		
		<byte:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Add" type="http://metalx.org/Integer" static="true">
		<cls:parameter name="Value1" type="http://metalx.org/Integer"/>
		<cls:parameter name="Value2" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullDIFromStack/>
		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:AddOperandToRegister/>
		<op:AX-SIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Subtract" type="http://metalx.org/Integer" static="true">
		<cls:parameter name="Value1" type="http://metalx.org/Integer"/>
		<cls:parameter name="Value2" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullDIFromStack/>
		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:SubtractOperandFromRegister/>
		<op:AX-SIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Multiply" type="http://metalx.org/Integer" static="true">
		<cls:parameter name="Value1" type="http://metalx.org/Integer"/>
		<cls:parameter name="Value2" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullDIFromStack/>
		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:MultiplyBySIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Divide" type="http://metalx.org/Integer" static="true">
		<cls:parameter name="Value1" type="http://metalx.org/Integer"/>
		<cls:parameter name="Value2" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullDIFromStack/>
		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToDX/>
		<int>0</int>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:DivideBySIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Mod" type="http://metalx.org/Integer" static="true">
		<cls:parameter name="Value1" type="http://metalx.org/Integer"/>
		<cls:parameter name="Value2" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullDIFromStack/>
		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyImmediateToDX/>
		<int>0</int>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:DivideBySIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DX-AXRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Add" type="http://metalx.org/Integer">
		<cls:parameter name="Value" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:AddOperandToRegister/>
		<op:AX-SIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Subtract" type="http://metalx.org/Integer">
		<cls:parameter name="Value" type="http://metalx.org/Integer"/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopySIAddressToAXAndIncrementSI/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:SubtractOperandFromRegister/>
		<op:AX-SIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Multiply" type="http://metalx.org/Integer">
		<cls:parameter name="Value" type="http://metalx.org/Integer"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:MultiplyBySIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Divide" type="http://metalx.org/Integer">
		<cls:parameter name="Value" type="http://metalx.org/Integer"/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopySIAddressToAXAndIncrementSI/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:ExclusiveOrRegisterWithOperand/>
		<op:DX-DXRegister/>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:DivideBySIAddress/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Mod" type="http://metalx.org/Integer">
		<cls:parameter name="Value" type="http://metalx.org/Integer"/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopySIAddressToAXAndIncrementSI/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:ExclusiveOrRegisterWithOperand/>
		<op:DX-DXRegister/>

		<cpu:ArithmeticDXAXOperandFunction/>
		<ari:DivideBySIAddress/>

		<cpu:CopyRegisterToOperand/>
		<op:DX-AXRegister/>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Increment" type="http://metalx.org/Integer">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:IncrementFunction/>
		<inc:IncrementSIAddress/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Decrement" type="http://metalx.org/Integer">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:IncrementFunction/>
		<inc:DecrementSIAddress/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Zero" type="http://metalx.org/Integer" static="true">
		<cpu:CopyImmediateToAX/>
		<int>0</int>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="One" type="http://metalx.org/Integer" static="true">
		<cpu:CopyImmediateToAX/>
		<int>1</int>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="NegativeOne" type="http://metalx.org/Integer" static="true">
		<cpu:CopyImmediateToAX/>
		<int>-1</int>

		<int:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToString" type="http://metalx.org/String">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:AX-SIAddress/>

		<int:ToString/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class" static="true">
		<cpu:CopyRegisterToOperand/>
		<op:BX-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>
</cls:class>